﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WinFormExam
{
    public partial class RegisterForm : Form
    {
        public RegisterForm()
        {
            InitializeComponent();
        }

        private void btnReg_Click(object sender, EventArgs e)
        {
        
            var uid = txtUserName.Text.Trim();
            var pwd = txtUserPwd.Text;
            var rePwd = txtRetryPassWord.Text;


            var isId = !string.IsNullOrEmpty(uid);
            var isPwd = !string.IsNullOrEmpty(pwd);
            var eqPwd = pwd == rePwd;
            if (isId && isPwd && eqPwd)
            {
                var sql = string.Format("select * from Users where UserName='{0}' and PassWord='{1}'", isId, isPwd);
                var dt = DbHelper.GetDataTable(sql);
                MessageBox.Show("注册成功","注册提示",MessageBoxButtons.OK, MessageBoxIcon.Information);
                
                Login.users.Add(uid, pwd);
                this.Close();
            }
            else
            {
                MessageBox.Show("注册失败", "注册提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                
            }
            


        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}

